<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/22
 * Time: 16:38
 */

namespace app\weixin\controller;
use think\Validate;
use think\Db;
class LawyerCooperate extends Base
{

    public function index(){
        $this->assign('title','律师入驻');
        return view();
    }

    //入驻
    public function add(){
        //接收form表单
        $post = $_POST;
        $rule = [
            'name'                 => 'require',
            'phone'                 => 'require|[1][3-9][0-9]{9}',
            'address'                 => 'require',
        ];
        $msg = [
            'name.require'         => '请输入姓名',
            'phone.require'         => '请输入电话号码',
            'phone'          => '请输入正确的电话号码',
            'address.require'         => '请输入地址',
        ];
        $validate = new Validate($rule, $msg);
        if(!$validate->check($post))
        {
            $this->error($validate->getError());
        }
        $data = Db::table('php_lication')->insert($post);
        if($data){
            return $this->ajaxReturn("已申请，等候通知",1);
        }else{
            return $this->ajaxReturn("申请失败",0);
        }
    }
}